package com.mogujie.tt.DB.sp;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

/**
 * Created by Administrator on 2015/10/23.
 */
public class GesturespasswordSp {

    public static final String AUTO_PLAY = "auto_play";
    public static final String DELETE_LOCK = "delete_lock";

    public static final String NEW_OROPWD = "new_oropwd";
    public static final String NEW_GESTURE = "new_gesture";
    public static final String NEW_NUM = "new_num";

    public static String getNUM(){
        return LoginSp.instance().getLockLoginId()+NEW_NUM;
    }

    public static String getGESTURE(){
        return LoginSp.instance().getLockLoginId()+NEW_GESTURE;
    }

    /**
     * 获取配置
     * @param context
     * @param name
     * @param defaultValue
     * @return
     */
    public static boolean get(Context context, String name, boolean defaultValue) {
        final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
        boolean value = prefs.getBoolean(name, defaultValue);
        return value;
    }

    /**
     * 保存用户配置
     * @param context
     * @param name
     * @param value
     * @return
     */
    public static boolean set(Context context, String name, boolean value) {
        final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
        SharedPreferences.Editor editor = prefs.edit();
        editor.putBoolean(name, value);
        return editor.commit(); //提交
    }

    /**
     * 获取配置
     * @param context
     * @param name
     * @param defaultValue
     * @return
     */
    public static String get(Context context, String name, String defaultValue) {
        final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
        String value = prefs.getString(name, defaultValue);
        return value;
    }

    /**
     * 保存用户配置
     * @param context
     * @param name
     * @param value
     * @return
     */
    public static Boolean set(Context context, String name, String value) {
        final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
        SharedPreferences.Editor editor = prefs.edit();
        editor.putString(name, value);
        return editor.commit(); //提交
    }



}
